620. Not Boring Movies


Posted by ikl258794613 on 2024-02-22

Column Name Type
id int
movie varchar
description varchar
rating float

id is the primary key (column with unique values) for this table.
Each row contains information about the name of a movie, its genre, and its rating.
rating is a 2 decimal places float in the range [0, 10]

Write a solution to report the movies with an odd-numbered ID and a description that is not "boring".

Return the result table ordered by rating in descending order.

The result format is in the following example.

Input:
Cinema table:

id movie description rating
1 War great 3D 8.9
2 Science fiction 8.5
3 irish boring 6.2
4 Ice song Fantacy 8.6
5 House card Interesting 9.1

Output:

id movie description rating
5 House card Interesting 9.1
1 War great 3D 8.9

Explanation:
We have three movies with odd-numbered IDs: 1, 3, and 5. The movie with ID = 3 is boring so we do not include it in the answer.

解答:

SELECT id, movie, description, rating
FROM Cinema
WHERE description != 'boring' 
HAVING MOD(id,2) = 1
ORDER BY rating DESC

#SQL







Related Posts

magick - 非常實用的圖片轉檔工具

magick - 非常實用的圖片轉檔工具

[ 筆記 ] JavaScript 進階 01 - 變數性質

[ 筆記 ] JavaScript 進階 01 - 變數性質

[MTR04] W2 D14 練習四:請寫出一個叫做 star 的 function 並且接受一個參數 n,能回傳 n 個 *。

[MTR04] W2 D14 練習四:請寫出一個叫做 star 的 function 並且接受一個參數 n,能回傳 n 個 *。


Comments